#!/bin/bash

# Function to check if gnome-control-center is running
is_gcc_running() {
    ps aux | grep -v grep | grep -q '/usr/bin/gnome-control-center'
    return $?
}


is_gnome_session_running() {
    ps aux | grep -v grep | grep -q '/usr/bin/gnome-session-properties'
    return $?
}


# Function to restart gnome-control-center
restart_gcc() {
    # echo 1|sudo -S shutdown now
    reboot
}

# Infinite loop to monitor the process
if is_gcc_running; then
    echo "gnome-control-center is running. Restarting..."
    restart_gcc
else
    echo "gnome-control-center is not running."
fi
# Sleep for a specified time before checking again (e.g., 10 seconds)


# 使用 pgrep 检查进程是否存在
if is_gnome_session_running; then
    echo "gnome-session-properties is running."
    restart_gcc
else
    echo "gnome-session-properties is not running."
fi
